
#include "dominion.h"
#include "dominion_helpers.h"
#include <string.h>
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include "rngs.h"

// set NOISY_TEST to 0 to remove printfs from output
#define NOISY_TEST 1

int main() {
    int i;
    int seed = 1000;
    int numPlayer = 2;
    int r;
    int loopCount;
    int k[10] = {adventurer, council_room, feast, gardens, mine
               , remodel, smithy, village, baron, great_hall};
    struct gameState G;
    int result;
    int hand = 2;
    int bonus = 0;
    int numberCards;
    int expctCard; 
	int expctBuys;
	int rndBuy;
	int numBuys;
	int rndNum;


    
    
#if (NOISY_TEST == 1)
                printf ("TESTING cardEffect council_room:\n"); // testing the number of cards
                
#endif
		loopCount = rand() % 999 + 1; //sets it from 1 to 1,000

        for(i = 0; i < loopCount; i++){
                memset(&G, 23, sizeof(struct gameState));   // clear the game state
                r = initializeGame(numPlayer, k, seed, &G); // initialize a new game
				
				rndNum = rand() % 26 + 4;
				rndBuy = rand() % 19 + 1;
		
				*G.handCount = rndNum; //set the number of cards in the hand to random, not just 4
				G.numBuys = rndBuy; //set the number of buys to random


                result=cardEffect(council_room, 0, 0, 0, &G, hand, &bonus);
                
				numBuys = G.numBuys;
				numberCards = *G.handCount;
				
				expctBuys = rndBuy + 1; //Council Room adds 1 to the number of buys
				expctCard = rndNum + 3; //Council Room adds 4 cards (minus discard)


#if (NOISY_TEST == 1)
                printf("Number of cards = %d, expected = %d\n", numberCards, expctCard);
				printf("Number of buys = %d, expected = %d\n", numBuys, expctBuys);
#endif
                assert(numberCards == expctCard); // check if the number of cards is correct
                assert(numBuys == expctBuys); //check if number of buys is correct
        }
    printf("All tests passed!\n");

    return 0;
}
